package com.zoke.daycarpool.parser;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.zoke.daycarpool.domain.ChannelBeen;

public class ChannelParser extends BaseCarParser<List<ChannelBeen>> {
	@Override
	public List<ChannelBeen> parseJson(String json) throws JSONException {
		List<ChannelBeen> list = new ArrayList<ChannelBeen>();
		JSONObject jo = getJsonObject(json);
		JSONArray array = jo.getJSONArray("result");
		for (int x = 0; x < array.length(); x++) {
			ChannelBeen been = new ChannelBeen();
			JSONObject joo = array.getJSONObject(x);
			been.setChId(joo.optString("chId"));
			been.setDest(joo.optString("dest"));
			been.setStart(joo.optString("start"));
			been.setNum(joo.optString("num"));
			been.setStartcode(joo.optString("startcode"));
			been.setDestcode(joo.optString("destcode"));
			list.add(been);
		}
		return list;
	}

}
